Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: make Day preserve time-of-day across DST transitions #55502

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Oct 12, 2023

Updated version of #51874.

I'm trying to find things to split off of this or do as bite-size deprecations. Not much optimism on those fronts. I expect we'll need to do this all-at-once in 3.0 or as a giant deprecation in 2.x with a future option.

update: ideas for bits to split off or deprecate

  • Day.__truediv__ and multiplication by non-int could be deprecated, this shouldn't be too painful for users since i doubt anyone actually uses it
  • deprecate allowing Timedelta(day_obj). Again should be rare
  • deprecate allowing Day objects for freq in TDI constructor

@mroeschke mroeschke added Frequency DateOffsets Timezones Timezone data dtype labels Oct 13, 2023
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Nov 15, 2023
@MarcoGorelli
Copy link
Member

MarcoGorelli commented Nov 17, 2023

I'm trying to find things to split off of this or do as bite-size deprecations. Not much optimism on those fronts. I expect we'll need to do this all-at-once in 3.0 or as a giant deprecation in 2.x with a future option.

all at once sounds fine to be honest, I'd consider it a bug that

In [44]: pd.Series([datetime(2020, 10, 25)]).dt.tz_localize('Europe/London') + pd.tseries.offsets.Day(1)
Out[44]:
0   2020-10-25 23:00:00+00:00
dtype: datetime64[ns, Europe/London]

happens

Please do ping when it's ready for review (looks like there's lots of conflicts atm)

@jbrockmendel
Copy link
Member Author

@jorisvandenbossche can i get you to take a look here pre-merge (which is not imminent)?

'D'
"""
if self.n != 1:
return str(self.n) + "D"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if self.n == 0 do we still need to show "0D"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s what it is ATM. What else would you suggest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK if it's the current behavior I suppose that's fine to keep it

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed there's quite a few places still where we convert Day to its hour equivalent and allow operations to still continue. IIRC back in the day I was hoping to converting Day to a non-fixed frequency and living with the consequences of Day and "D" having non-fixed frequency semantics throughout other operations (which I would imagine be for things to raise more)

Are the conversions of Day to hours needed for this change to be less breaking?

@jbrockmendel
Copy link
Member Author

Are the conversions of Day to hours needed for this change to be less breaking?

IIRC they were for either a) cases where we went DatetimeIndex->TimedeltaIndex (e.g. subtracting a scalar from DatetimeIndex) or b) to allow users to continue to pass freq="2D" to TimedeltaIndex-like functions. The latter could be disallowed either directly or via deprecation.

I'll take another pass and see if any of these usages can be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frequency DateOffsets Stale Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: Make 'D' & offsets.Day always operate as calendar day instead of 24 Hour
3 participants